function checkLocation(seq) {

	var cnt = document.kitMakingForm.count.value;

	if ( parseInt ( cnt ) != 1 )
	{
		str = eval('document.kitMakingForm.select['+seq+'].checked');
	}
	else
	{
		str = eval('document.kitMakingForm.select.checked');
	}
	var maxVal = 0;
						
	if(cnt!=1)
	{	
		if(str==false)
		{
			document.kitMakingForm.priority[seq].disabled=false;
			// added to set the default priority by ravikanth
			maxVal =  document.kitMakingForm.priority[seq].value;
			for ( var y =0 ; y < cnt ; y++ )
			{
				temp   = parseInt ( document.kitMakingForm.priority[y].value );
				if( temp > maxVal && maxVal != 0)
				{
					document.kitMakingForm.priority[y].value = parseInt(document.kitMakingForm.priority[y].value) -1;
					document.kitMakingForm.priority[y].disabled = true;
				}
			}
			document.kitMakingForm.priority[seq].disabled=false;
			document.kitMakingForm.priority[seq].value='';
			document.kitMakingForm.priority[seq].disabled = true;
		}
		if(str==true)
		{
			document.kitMakingForm.priority[seq].disabled=false;
			for ( var y =0 ; y < cnt ; y++ )
			{
				temp   = parseInt ( document.kitMakingForm.priority[y].value );
				if( temp > maxVal)
				{
					maxVal = temp
				}
				document.kitMakingForm.priority[y].disabled = true;
			}		
			document.kitMakingForm.priority[seq].value= parseInt(maxVal)+1 ;
			document.kitMakingForm.priority[seq].disabled = true;
		}
	}
	else
	{
		if(str==false)
		{
			document.kitMakingForm.priority.disabled=true;
			document.kitMakingForm.priority.value= '';
		}
		if(str==true)
		{
			document.kitMakingForm.priority.value= 1;
			document.kitMakingForm.priority.diabled = true;
		}
   }
}



function whileLoad()
{
	var cnt = document.kitMakingForm.count.value;

	if ( cnt == 1 )
	{ 
		//str = eval('document.kitMakingForm.select.checked');
		str = document.kitMakingForm.select.checked;
		if(str==false)
		{
			document.kitMakingForm.priority.disabled=true;
		}
		if(str==true)
		{
			document.kitMakingForm.priority.disabled=false;
		}
	}
	else
	{
		for(var i=0;i<cnt;i++)
		{
			//str = eval('document.kitMakingForm.select['+i+'].checked');
			str = document.kitMakingForm.select[i].checked;
			if(str==false)
			{
				document.kitMakingForm.priority[i].disabled=true;
			}
			else if(str==true)
			{
				document.kitMakingForm.priority[i].disabled=false;
			}
		}
	}
}



function checkValuesForBoardMaking()
{
    var cnt = document.kitMakingForm.count.value;
    var pa  = document.getElementById("errors");
    if(cnt==1)
    { 
		str = eval('document.kitMakingForm.select.checked');
		
		if(str==true)
		{
			document.kitMakingForm.priority.value = document.kitMakingForm.priority.value.trim();
			var priority = document.kitMakingForm.priority.value;
			if ( priority.length != '' )
			{
				//if ( checkInteger ( priority.trim(), 'Priority', 'Y' ) == false )
				if ( isInteger ( priority ) == false )
				{
					pa.innerHTML = "Please enter valid Priority, It must be number";
					document.kitMakingForm.priority.select();
					document.kitMakingForm.priority.focus();
					return false;
				}
			}
			else 
			{
				pa.innerHTML = "Please enter Priority, It must be number";
				document.kitMakingForm.priority[i].select();
				document.kitMakingForm.priority[i].focus();
				return false;
			}
		}
	}

    else
    {
		var selects = document.kitMakingForm["select"];
        for(var i=0;i<cnt;i++)
		{
			str = selects[i].checked;
			if(str==true)
			{
				document.kitMakingForm.priority[i].value = document.kitMakingForm.priority[i].value.trim();
				var priority = document.kitMakingForm.priority[i].value;
				if ( priority.length != '' )
				{
					//if ( checkInteger ( priority.trim(), 'Priority', 'Y' ) == false )
					if ( isInteger ( priority ) == false )
					{
						pa.innerHTML = "Please enter valid Priority, It must be number";
						document.kitMakingForm.priority[i].select();
						document.kitMakingForm.priority[i].focus();
						return false;
					}
					for ( var jj = i+1; jj < cnt ; jj++)
					{
						if ( priority == document.kitMakingForm.priority[jj].value.trim() )
						{
							pa.innerHTML = "Please enter a different Priority Number";
							return false;
						}
					}
				}
				else
				{
					pa.innerHTML = "Please enter Priority, Blank values are not permitted";
					document.kitMakingForm.priority[i].select();
					document.kitMakingForm.priority[i].focus();
					return false;
				}
			}
		}
    }
	
    if(cnt!=1)
	{
		for(var i=0;i<cnt;i++)
		{
			document.kitMakingForm.priority[i].disabled=false;
			document.kitMakingForm.locationName[i].disabled=false;
		}
    }
    else
    {
		document.kitMakingForm.priority.disabled=false;
		document.kitMakingForm.locationName.disabled=false;
    }
    return true;
}


function vendorValidations(form)
{
	var pa	= document.getElementById("errors");
	var num = form.priority.length;
	var retVal = false;
	if ( form.priority.length == null )
	{
		var singleVendor = eval("form.select");
		if ( ( singleVendor.checked == true ) && ( form.priority.value.length > 0) )
		{
			retVal = true;
		}
	}
	for ( var len = 0; len < num; len++)
	{
		var temp = eval ("form.select["+len+"]");
		if ( ( temp.checked == true ) && ( form.priority[len].value.length > 0 ) )
		{
			retVal = true;
		}
	}
	return retVal
}


function checkChildBoards ()
{
	var bool = false;
	var form = document.kitMakingForm;
	var pa = document.getElementById("childProductId");
	if ( pa == null )
	{
		bool = false;
	}
	else if ( form.childProductId.length == null )
	{
		if ( ( form.originalChildBoardName.value.trim().length == 0 ) && ( form.childBoardName.value.trim().length == 0 ) )
		{
			bool = false;
		}
		else if ( ( form.originalChildBoardName.value.trim().length > 0 ) && ( form.childBoardName.value.trim().length == 0 ) )
		{
			bool = false;
		}
		else
		{
			bool = true;
		}
	}
	else
	{
		for (var aa = 0; aa < form.childProductId.length; aa++ )
		{
			if ( form.childBoardName[aa].value.trim().length > 0 )
			{
				bool = true;
			}
		}
	}
	return bool;
}
	

/*
This method must be called only after the checkChildBoards. The reason can be 
attributed to the presence of old records in database without any child records.
*/
function checkPartNumber ()
{
	var bool = true;
	var form = document.kitMakingForm;
	var parentPartNumber = form.partNumber.value;

	if( form.childProductId != null)
	{
		if ( form.childProductId.length == null )
		{
			if ( parentPartNumber.toUpperCase() == form.childBoardName.value.toUpperCase().trim() )
			{
				bool = false;
			}
		}
		else
		{
			for ( var aa = 0; aa < form.childProductId.length; aa++ )
			{
				if ( parentPartNumber.toUpperCase() == form.childBoardName[aa].value.toUpperCase().trim() )
				{
					focusNum = aa;
					bool = false;
				}
			}
		}
	}
	return bool;
}


function checkChildPartNumbers ()
{
	var bool = -1;
	var form = document.kitMakingForm;

	if( form.childProductId != null)
	{
		if ( form.childProductId.length == null )
		{
			bool = -1;
		}
		else
		{
			for (var aa = 0; aa < form.childProductId.length; aa++ )
			{
				form.childBoardName[aa].value = form.childBoardName[aa].value.trim();
				for (var bb = 0; bb < form.childProductId.length; bb++ )
				{
					form.childBoardName[bb].value = form.childBoardName[bb].value.trim();
					if ( parseInt ( aa ) != parseInt ( bb ) )
					{
						if ( form.childBoardName[aa].value.trim().length > 0 && form.childBoardName[bb].value.trim().length > 0 )
						{
							if ( form.childBoardName[aa].value.toUpperCase().trim() == form.childBoardName[bb].value.toUpperCase().trim() )
							{
								bool = bb;
							}
						}
					}
				}
			}
		}
	}
	return bool;
}


function checkDeletion ()
{
	var bool = true;
	var form = document.kitMakingForm;

	if( form.childProductId != null)
	{
		if ( form.childProductId.length == null )
		{
			if ( form.childProductId.value == '-1' )
			{
				return true;
			}
			else
			{
				if ( ( form.childBoardName.value.trim().length == 0 ) && ( form.originalChildBoardName.value.trim().length > 0 ) )
				{
					form.childBoardName.value = form.originalChildBoardName.value;
					form.childBoardName.focus();
					bool = false;
				}
			}
			return true;
		}
		else
		{
			for ( var aa = 0; aa < form.childProductId.length; aa++ )
			{
				if ( form.childProductId[aa].value == '-1' )
				{
					return true;
				}
				else
				{
					if ( ( form.childBoardName[aa].value.trim().length == 0 ) && ( form.originalChildBoardName[aa].value.trim().length > 0 ) )
					{
						form.childBoardName[aa].value = form.originalChildBoardName[aa].value;
						form.childBoardName[aa].focus();
						bool = false;
					}
				}
			}
		}
	}
	return bool;
}

























/*function saveFinishedGoods()
{
	var cnt						= document.kitMakingForm.count.value;
	var pa						= document.getElementById("message");
	var min_Level				= document.kitMakingForm.minLevel.value;
	var max_Level				= document.kitMakingForm.maxLevel.value;
	var re_oreder_level         = document.kitMakingForm.reorderLevel.value;
	var partNumber 				= document.kitMakingForm.productName.value;
	document.kitMakingForm.mftPartNumber.value = partNumber;
    // -- END --

	if(re_oreder_level!='')
	{
		if (!isInteger(re_oreder_level))
		{
			pa.innerHTML = "Please enter valid Re Order Level,It must be number";	
			document.kitMakingForm.reorderLevel.select();
			document.kitMakingForm.reorderLevel.focus();
			return;
		}
	}
	
	if(min_Level!='')
	{
		if (!isInteger(min_Level))
		{
			pa.innerHTML = "Please enter valid Min Level,It must be number";	
			document.kitMakingForm.minLevel.select();
			document.kitMakingForm.minLevel.focus();
			return;
		}
	}

	if(max_Level!='')
	{
		if(!isInteger(max_Level))
		{	
			pa.innerHTML = "Please enter valid Max Level,It must be number";
			document.kitMakingForm.maxLevel.select();
			document.kitMakingForm.maxLevel.focus();
			return;
		}	
	}

	if(cnt==1)
	{
		str = eval('document.kitMakingForm.select_0.checked');
		if(str==true)
		{
			var priority = document.kitMakingForm.priority.value;
			if(priority!='')
			{
				if (!isInteger(priority))
				{
					pa.innerHTML = "Please enter valid Priority,It must be number";
					document.kitMakingForm.priority.select();
					document.kitMakingForm.priority.focus();
					return;
				}
			}
		}
	}

	else
	{
		for(var i=0;i<cnt;i++)
		{
			str = eval('document.kitMakingForm.select_'+i+'.checked');
			if(str==true)
			{
				var priority = document.kitMakingForm.priority[i].value;
				if(priority!='')
				{
					if (!isInteger(priority))
					{
						pa.innerHTML = "Please enter valid Priority,It must be number";
						document.kitMakingForm.priority[i].select();
						document.kitMakingForm.priority[i].focus();
						return;
					}
				}
			}
		}
	}

	if(cnt!=1)
	{
		for(var i=0;i<cnt;i++)
		{
			document.kitMakingForm.priority[i].disabled=false;
			document.kitMakingForm.locationName[i].disabled=false;
		}
	}

	else
	{
		document.kitMakingForm.priority.disabled=false;
		document.kitMakingForm.locationName.disabled=false;
	}
	document.kitMakingForm.submit();
}*/










/*
function checkLocation(checkBoxCount)
{
	var selects = document.kitMakingForm["select"];	
	var cnt = document.kitMakingForm.count.value;
	var maxValue = 0;
	if(cnt!=1)
	{
		if ( selects[checkBoxCount].checked == false)
		{
			maxValue = document.kitMakingForm.priority[checkBoxCount].value;
		}
		
		for ( var ss =0 ; ss < cnt; ss++ )
		{
			str = selects[ss].checked;
			if ( str == false )
			{
				temp = document.kitMakingForm.priority[ss].value

				if( parseInt ( temp ) > parseInt ( maxValue ) && ( parseInt ( maxValue ) != 0 ) )
				{
					document.kitMakingForm.priority[y].value = parseInt( document.kitMakingForm.priority[y].value ) -1;
				}
				document.kitMakingForm.priority[checkBoxCount].value='';
				document.kitMakingForm.priority[checkBoxCount].disabled=true;
			}

			if ( str == true )
			{
				temp = document.kitMakingForm.priority[ss].value;
				document.kitMakingForm.priority[ss].disabled=false;
				alert ( 'crum : '+maxValue );
				if ( parseInt ( maxValue ) > parseInt ( temp ) )
				{
					alert ('entered if tempValue is : '+temp);
				}
				else
				{
					maxVal = temp
					alert ('entered else tempValue is : '+temp);
				}
				document.kitMakingForm.priority[checkBoxCount].value = parseInt ( maxVal ) + 1;
			}
		}
		document.kitMakingForm.priority[checkBoxCount].disabled = false
	}
	
	else
	{
		str = document.kitMakingForm.select.checked;
		if(str==false)
		{
			document.kitMakingForm.priority.disabled=true;
			document.kitMakingForm.priority.value='';
		}
		
		if(str==true)
		{
			document.kitMakingForm.priority.disabled=false;
			document.kitMakingForm.priority.value=1;
		}
	}
}



*/